<?php
declare (strict_types=1);

namespace app\admin\controller\student;

use think\facade\Request;
use app\common\service\StudentActionAbsence as S;
use app\common\model\StudentActionAbsence as M;

class ActionAbsence extends \app\admin\controller\Base
{
    protected $middleware = ['AdminCheck', 'AdminPermission'];

    // 列表
    public function index()
    {
        return $this->getAuto($this->fetch(), M::getList());
    }

    // 添加
    public function add()
    {
        $student_id = input('param.student_id', '');
        $class_id = input('param.class_id', '');
        return $this->getAuto($this->fetch('', [
            'student_id' => $student_id,
            'class_id' => $class_id,
            'admin_id' => session('admin.id')
        ]), S::goAdd(Request::post()));
    }

    // 编辑
    public function edit($id)
    {
        return $this->getAuto($this->fetch('', ['model' => M::find($id)]), S::goEdit(Request::post(), $id));
    }

    // 状态
    public function status($id)
    {
        return $this->getJson(S::goStatus(Request::post('status'), $id));
    }

    // 删除
    public function remove($id)
    {
        return $this->getJson(S::goRemove($id));
    }

    // 批量删除
    public function batchRemove()
    {
        return $this->getJson(S::goBatchRemove(Request::post('ids')));
    }

    // 回收站
    public function recycle()
    {
        return $this->getAuto($this->fetch(), S::goRecycle());
    }

}
